<template>
	<section>
		<el-col :span="12" class="toolbar">
			<el-form label-width="100px" >
				<el-form-item label="跑马灯内容">
					<el-input v-model="content.content" placeholder="跑马灯内容" type="textarea" :rows="8" ></el-input>
				</el-form-item>
				<el-form-item>
					<el-button type="primary" size="medium" @click="handleAdd">发布</el-button>
				</el-form-item>
			</el-form>
		</el-col>
	</section>
</template>
<script>
    export default {
        data(){
            return{
                content:{
                    content:''
                }
            }
        },
        created(){
            this.getList()
        },
        methods:{
            getList(){
                // this.content.content = '六六棋牌是一个24小时全真人，无外挂，最稳定的大型娱乐平台，如对游戏有任何建议意见请大家添加官方客服微信！\n' +
                //     '欢迎来到六六棋牌娱乐，我们为大家定制各种娱乐游戏，希望大家愉快的游戏，保持良好的心态！祝大家游戏必胜！'
                this.$axios.get('/notice',{},this.global().token).then((res)=>{
                    if (res.status == 200){
                        this.content.content = res.data
                    }else{
                        this.$message({message: res.data, type: 'error'});
                    }
                })
            },
            handleAdd(){
                if (this.content.content == ''){
                    this.$message({message: '跑马灯不能为空', type: 'error'});
                }else{
                    this.$axios.patch('/notice',this.content,this.global().token).then((res)=>{
                        if (res.status == 200){
                            this.$message({message: '发布成功', type: 'success'});
                            this.getList()
                        }else{
                            this.$message({message: res.data, type: 'error'});
                        }
                    })
                }
            }
        }
    }
</script>
<style scoped lang="stylus">
	.toolbar
		padding-top:30px
	.toolbar .el-form-item
		margin-bottom 30px
</style>